<?php 
/* 
@author Cecil O. Almonte
Email : info@cecilomar.com
URL : http://www.cecilomar.com/pojects/webdevtools
Description : Some Web Develpment tools like:
	* CSS Refresh
	* W3C Code Checker
*/
/// no direct access 
defined('_JEXEC') or die('Restricted access'); 


///////////////////////////////////////////////////////////////////////////////////////////////////////
// Get parameters 
///////////////////////////////////////////////////////////////////////////////////////////////////////

$cache							= $params->get('cache');
$usergroups						= $params->get('usergroups'); 
$tool['refresh_css']			= $params->get('refresh_css'); 
$tool['validate_feed']			= $params->get('validate_feed'); 
$tool['validate_css']			= $params->get('validate_css'); 
$tool['validate_html']			= $params->get('validate_html'); 
$tool['validate_links']			= $params->get('validate_links'); 
$tool['validate_section508']	= $params->get('validate_section508'); 
$tool['validate_wai']			= $params->get('validate_wai'); 


///////////////////////////////////////////////////////////////////////////////////////////////////////
// Validators Tool ////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

if($tool['validate_feed'] or $tool['validate_css'] or $tool['validate_html'] or $tool['validate_links'] or $tool['validate_section508'] or $tool['validate_wai']){

// Creating a link for the validators.
$encodeduri = 'http';
if ($_SERVER["HTTPS"] == "on") {
	$encodeduri .= "s";
}
$encodeduri .= "://";
if ($_SERVER["SERVER_PORT"] != "80"){
	$encodeduri .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
	$encodeduri .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$encodeduri = urlencode($encodeduri);

// Creating a list of the validators
?>
<ul>
<?php
if($tool['validate_css']){ ?>
	<li><a href="http://jigsaw.w3.org/css-validator/validator?profile=css21&warning=0&uri=<?php echo $encodeduri; ?>" target="_blank">Validate CSS</a></li>
<?php } 

if($tool['validate_feed']){ ?>
	<li><a href="http://validator.w3.org/feed/check.cgi?url=<?php echo $encodeduri; ?>" target="_blank">Validate Feed</a></li>
<?php }

if($tool['validate_html']){ ?>
	<li><a href="http://validator.w3.org/check?verbose=1&uri=<?php echo $encodeduri; ?>" target="_blank">Validate HTML</a></li>
<?php }

if($tool['validate_links']){ ?>
	<li><a href="http://validator.w3.org/checklink?check=Check&hide_type=all&summary=on&uri=<?php echo $encodeduri; ?>" target="_blank">Validate Links</a></li>
<?php }

if($tool['validate_section508']){ ?>
	<li><a href="http://www.cynthiasays.com/mynewtester/cynthia.exe?rptmode=-1&url1=<?php echo $encodeduri; ?>" target="_blank">Validate Section 508</a></li>
<?php }

if($tool['validate_wai']){ ?>
	<li><a href="http://www.cynthiasays.com/fulloptions.asp?rptmode=2&url1=<?php echo $encodeduri; ?>" target="_blank">Validate WAI</a></li>
<?php
}
?>
</ul>
<?php 
}


///////////////////////////////////////////////////////////////////////////////////////////////////////
// Refresh CSS Tool ////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

if($tool['refresh_css']){ ?>

<script type="application/javascript">

function updateStylesheets() {
	var i,a,s;
	a=document.getElementsByTagName('link');
	for(i=0;i<a.length;i++) {
		s=a[i];
		if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {
			var h=s.href.replace(/(&|\\?)forceReload=d /,'');
			s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf());
		}
	}
}

</script>
	<input type="submit" name="CSS" id="CSS" value="Refresh CSS" onClick="Javascript:updateStylesheets()">


<?php } ?>